import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Jun Xu
 * Date：2024/1/4
 * Time: 19:09
 */
public class Method_test {



    // 写一个递归方法，输入一个非负整数，返回组成它的数字之和. 例如，输入 1729, 则应该返回
    //1+7+2+9，它的和是19
    /*public static void main(String[] args) {
        int num = 1729;
        System.out.println(add(num));

    }
    public static int add(int num){
        if(num < 10) return num;
        return num % 10 + add(num / 10);
    }*/


    /*//递归求1+2+3+...+10
    public static void main(String[] args) {
        int sum = 10;
        System.out.println(add(sum));
    }
    public static int add(int sum){
        int n = 0;
        if(sum > 0){
            n = sum += add(sum-1);
        }
        return n;
    //int num = sum + add(sum - 1);

    }*/


    //按顺序打印出一个数的各个组成数字
    //打印出1234 1 2 3 4
    /*public static void main(String[] args) {
        System.out.println("请输入你要打印的数: ");
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        fanc(num);
    }

    public static void fanc(int num){
        if(num != 0){
            fanc(num/10);
            System.out.printf("%d  ",num % 10);

        }*/

    //}

    /*public static void main(String[] args) {
        int a = 10;
        int b = 20;
        swap(a,b);
        System.out.println("main a= "+a + "b= "+b);

    }
    public static void swap(int a ,int b){
        int tmp = a;
        a = b;
        b = tmp;
        System.out.println("swap a = "+a + "b = "+b);

    }*/
}
